/*
   Copyright 2009 Abdulla Abdurakhmanov (abdulla@latestbit.com)
   Original sources are available at www.latestbit.com

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/

package org.latestbit.smartobjects.network;

import java.io.IOException;
import java.net.URI;

import org.latestbit.smartobjects.exceptions.IncorrectURIException;

/**
 * Interface describes all low-level (non-managed) network factory methods.
 * @author abdulla-a
 *
 */
public interface INetworkFactory {
	/**
	 * Creates a new acceptor
	 * @return the acceptor instance
	 * @throws IncorrectURIException
	 * @throws IOException
	 */
	public IAcceptor createAcceptor() throws IncorrectURIException, IOException;
	
	/**
	 * Creates a new acceptor on the specified URI 
	 * @param location URI information
	 * @return the acceptor instance
	 * @throws IncorrectURIException
	 * @throws IOException
	 */
	public IAcceptor createAcceptor(URI location) throws IncorrectURIException, IOException;
	
	/**
	 * Creates a new connector
	 * @return the connector instance
	 * @throws IncorrectURIException
	 * @throws IOException
	 */
	public IConnector createConnector()	throws IncorrectURIException, IOException;
	
	/**
	 * Creates a new connector and specified server acceptor location URI
	 * @param location acceptor location URI
	 * @return the connector instance
	 * @throws IncorrectURIException
	 * @throws IOException
	 */
	public IConnector createConnector(URI location)	throws IncorrectURIException, IOException;
	
	/**
	 * Sets the specified packet former factory
	 * @param formerFactory the packet former factory. Can be null, if a packet former not required
	 */
	public void setPacketFormerFactory(IPacketFormerFactory formerFactory);
	
	/**
	 * Gets current packet former factory instance
	 * @return the packet former factory instance
	 */
	public IPacketFormerFactory getPacketFormerFactory();

	/**
	 * Sets the specified handshake manager factory
	 * @param factory the packet former factory. Can be null, if a packet former not required
	 */	
	public void setHandshakeManagerFactory(IHandshakeManagerFactory factory);
	
	/**
	 * Gets current handshake manager factory
	 * @return the handshake manager factory instance
	 */
	public IHandshakeManagerFactory getHandshakeManagerFactory();	
	
	/**
	 * Destroy all shared data linked with this network factory instance
	 */
	public void destroy();
}
